
<script type="text/javascript" src="/back/js/plugins/jquery.alerts.js"></script>
<!--<script type="text/javascript" src="/back/js/plugins/jquery.dataTables.min.js"></script>-->
<script>
    $(document).ready(function() {        
        $('.confirmbutton').click(function(){            
            var _this = this;
            jConfirm('Вы действительно хотите удалить материал?', 'Confirmation Dialog', function(r) {
                //jAlert('Confirmed: ' + r, 'Confirmation Results');
                if (r) {
                    window.location.href = $(_this).attr('href');
                }                
            });
            return false;
        });
    })
</script>

<div class="centercontent">
    <div class="pageheader">
        <h1 class="pagetitle">Управление контентом</h1> 
        <ul class="buttonlist">                   
            <li><a href="/admin/content" class="btn btn_blue btn_link"><span>Все (<?php echo $this->total; ?>)</span></a></li>
            <?php foreach ($this->categories as $category): ?>
                <li>
                    <a href="/admin/content/index/type/<?php echo $category['type']; ?>" class="btn btn_blue btn_link">
                        <span><?php echo $category['type']; ?> (<?php echo $category['count']; ?>)</span>
                    </a>
                </li>
            <?php endforeach; ?>                        
        </ul>
    </div>    
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
        <colgroup>
            <col class="con0" />
            <col class="con1" />
            <col class="con0" />
            <col class="con1" />                        
        </colgroup>
        <thead>
            <tr>
                <th class="head0">Имя</th>
                <th class="head1">Категория</th>
                <th class="head0">Кафедра</th>
                <th class="head1">Дата создания</th>
                <th class="head0">Действия</th>                            
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th class="head0">Имя</th>
                <th class="head1">Категория</th>
                <th class="head0">Кафедра</th>
                <th class="head1">Дата создания</th>
                <th class="head0">Действия</th>                            
            </tr>
        </tfoot>
        <tbody>
            <?php foreach ($this->content as $content): ?>
                <?php if ($content['is_visible'] == 0) { ?>
                    <tr style="background-color: #FF9966;">
                <?php } else { ?>
                    <tr>
                <?php } ?>                
                    <td><?php echo $content['title']; ?></td>
                    <td><?php echo $content['category_name']; ?></td>
                    <td><?php echo $content['department_name']; ?></td>
                    <td><?php echo $content['date_create']; ?></td>
                    <td>
                        <a href="<?php echo $this->url(array(
                                'module'     => 'admin',
                                'controller' => 'content',
                                'action'     => 'edit-post',
                                'post_id'    => $content['id']
                            )); ?>" class="stdbtn">
                            Редактировать
                        </a>
                        &nbsp;|&nbsp;
                        <a href="<?php echo $this->url(array(
                                'module'     => 'admin',
                                'controller' => 'content',
                                'action'     => 'delete-post',
                                'post_id'    => $content['id']
                            ));?>" class="anchorbutton confirmbutton">
                            Удалить
                        </a>
                        &nbsp;|&nbsp;
                        <a href="<?php echo $this->url(array(
                                'module'     => 'admin',
                                'controller' => 'content',
                                'action'     => 'change-visible-post',
                                'post_id'    => $content['id'],
                                'status'     => $content['is_visible']
                            )); ?>" class="stdbtn">
                            <?php echo (int)$content['is_visible']?'Скрыть':'Показать'; ?>
                        </a>
                    </td>                                
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>      
</div>